<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* 
      https://leetcode-cn.com/problems/jian-sheng-zi-ii-lcof/
      思路：https://leetcode-cn.com/problems/jian-sheng-zi-ii-lcof/solution/jian-sheng-zi-ii-shu-xue-gui-lu-de-zui-you-jie-by-/
    */
    function cuttingRope(n) {
      let arr =[0, 0, 1, 2, 4]
      if (n < 5)  return arr[n]
      let max = 1e9+7
      let res = 1
      while (n >= 5) {
        res = res * 3 % max
        n -= 3
      }
      return res * n % max
    }
  </script>
</body>
</html>